package com.feng.web;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.feng.model.DataGrid;
import com.feng.model.Users;
import com.feng.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
	private static Log log = LogFactory.getLog(UserController.class);
	@Autowired
	private UserService userService;
	
	
	@RequestMapping(value = "/users")
	@ResponseBody
	public  DataGrid lists(int page,int rows,String sort,String order){
		DataGrid datagrid = new DataGrid();
		List<Users> list = null;
		log.debug("将调用数据库");
		try {
			list = userService.findUsers(new Users());
		} catch (Exception e) {
			log.error("查询数据异常", e);
		    return null;
		}
		datagrid.setTotal((long)list.size());
		datagrid.setRows(list);
		return datagrid;
		
	}
}
